#include "parser.h"
#include "predict.h"
#include <iostream>

using namespace std;

int main() 
{
    parser::Parser *parser = nullptr;
    
    // Predict Method
    cout << "Input Expression: ";

    string expr;
    cin >> expr;
    // Default Rule
    parser::SyntaxRule DEFAULT_SYNTAX_RULE = 
    {
        // pay attention on the order of Vns, if the order is wrong,
        // then the FOLLOW of left symbol may have not been obtained yet when get_follow_set is invoked.
        {'F', 'B', 'T', 'A', 'E'},
        {'+', '*', '(', ')', 'i'},
        {
            {'E', "TA"},
            {'A', "+TA"},
            {'A', "$"},
            {'T', "FB"},
            {'B', "*FB"},
            {'B', "$"},
            {'F', "(E)"},
            {'F', "i"},
        },
        '$',
        'E'
    };

    // OR:  `parser = new PredictParser(DEFAULT_SYNTAX_RULE);`
    parser::PredictParser concreteParser(DEFAULT_SYNTAX_RULE);
    parser = &concreteParser;

    parser->Parse(expr);
}